package Data::Conveyor::Service::Result::Container;

# $Id: Result.pm 12894 2007-03-15 13:04:42Z gr $
#
# Contains a list of other result objects, which can include other
# containers, since they derive from the same subclass as "normal" service
# result objects such as scalars and tables.

use strict;
use warnings;
use YAML;


our $VERSION = '0.02';


use base 'Data::Conveyor::Service::Result';

# don't subclass Data::Container, since we have a slightly different API - we
# use 'result' instead of 'items', for example.


__PACKAGE__->mk_array_accessors(qw(result));


# concatenate the stringifications of the result list

sub result_as_string {
    my $self = shift;
    join "\n" => map { "$_" } $self->result;
}


# Here exception() is a method, not an attribute. You can't set an exception
# on a container directly; rather, if elements of the result list have
# exceptions, they will be returned in an exception container. If there are no
# exceptions in the results, undef will be returned.

sub exception {
    my $self = shift;
    my @exception = grep { defined } map { $_->exception } $self->result;
    return unless @exception;
    my $container = $self->delegate->make_obj('exception_container');
    $container->items(@exception);
    $container;
}


1;


__END__

{% USE p = PodGenerated %}

=head1 NAME

{% p.package %} - stage-based conveyor-belt-like ticket handling system

=head1 SYNOPSIS

    {% p.package %}->new;

=head1 DESCRIPTION

None yet. This is an early release; fully functional, but undocumented. The
next release will have more documentation.

=head1 METHODS

=over 4

{% p.write_methods %}

=back

{% p.write_inheritance %}

{% PROCESS standard_pod %}

=cut

